package esi.t2no1.ws.impl;

import org.springframework.beans.factory.annotation.Autowired;

import esi.t2no1.dao.contract.ContractDAO;
import esi.t2no1.dao.loadprofile.LoadProfileDAO;
import esi.t2no1.ws.model.LoadProfileInput;
import esi.t2no1.ws.model.LoadProfileOutput;
import esi.t2no1.ws.model.QualitySeriesInput;
import esi.t2no1.ws.service.MeteringService;

/**
 * For the description of the class, check the implemented interface.
 * 
 * @author Reimo Rebane
 */
public class MeteringServiceImpl implements MeteringService {

	private LoadProfileDAO loadProfileDAO;

	@Override
	public LoadProfileOutput submitLoadProfile(LoadProfileInput loadProfileInput) {
		LoadProfileOutput output = new LoadProfileOutput();
		if (validateLoadProfile(loadProfileInput)) {
			loadProfileDAO.createLoadProfile(loadProfileInput.getLoadProfile());
			output.setLoadProfile(loadProfileInput.getLoadProfile());
		}
		return output;
	}

	@Override
	public Boolean submitQualitySeries(QualitySeriesInput qualitySeriesInput) {
		// We don't have to do anything here

		return Boolean.TRUE;
	}

	private boolean validateLoadProfile(LoadProfileInput loadProfileInput) {
		// Validation might needed, currently not implemented
		return true;
	}

	@Autowired
	public void setLoadProfileDAO(LoadProfileDAO loadProfileDAO) {
		this.loadProfileDAO = loadProfileDAO;
	}
}
